import QtQuick
import QtQuick.Layouts
import QtMultimedia

Window {
    width: 1280
    height: 720
    visible: true
    title: qsTr("Hello World")
    Rectangle {
        anchors.fill: parent
        color: "#000000"
        Flow {
            anchors.fill: parent
            //星舰再入大气层烧毁特效
            Rectangle {
                width: 400
                height: 400
                layer.enabled: true
                layer.effect: ShaderEffect {
                    //控制时间单位秒
                    property real iTime: 0.1
                    //控制在xy方向上的占比
                    property vector3d iResolution: Qt.vector3d(0.8,0.8,0.0)

                    fragmentShader: "/Starship_reentry.frag.qsb"
                    Timer {
                        //以80毫秒为步进推动时间前进,间隔越短越流畅,但占用GPU资源也多
                        interval: 80; running: true; repeat: true
                        onTriggered: iTime += 0.08
                    }
                }
            }
            MediaPlayer {
                source: "H:/99.mp4"
                autoPlay: true
                videoOutput: video_view
            }
            VideoOutput {
                id: video_view
                width: 640; height: 360
                fillMode: VideoOutput.PreserveAspectFit
            }
            //可以将任意的item转化为texture，使其成为ShaderEffect的纹理输入
            ShaderEffectSource {
                id: source_video
                sourceItem: video_view
            }
            ShaderEffect {
                width: 320
                height: 180
                property variant source: source_video
                fragmentShader: "/effect.frag.qsb"
            }

            //黑白
            Image {
                id: img
                width: 400
                height: 200
                fillMode: Image.Stretch
                source: "wallhaven-gp17xe.jpg"
                layer.enabled: true
                layer.effect:  ShaderEffect {
                    fragmentShader: "/effect.frag.qsb"
                }
            }

            Image {
                id: round_img
                width: 400
                height: 200
                fillMode: Image.Stretch
                source: "wallhaven-gp17xe.jpg"
                layer.enabled: true
                layer.effect:  ShaderEffect {
                    property real radius: 100.0
                    property vector2d size: Qt.vector2d(round_img.width,round_img.height)
                    fragmentShader: "/round.frag.qsb"
                }
            }



        }
    }
}
